package com.smooth.site.sx.pc.job.controller.yaoqinghan;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.smooth.common.pc.interceptor.PcAccountContext;
import com.smooth.common.site.common.enums.SiteCodeEnums;
import com.smooth.common.site.common.excep.SiteException;
import com.smooth.common.site.common.rsp.ReturnResult;
import com.smooth.dao.gen.bean.BizCompany;
import com.smooth.dao.gen.bean.BizJobApplay;
import com.smooth.dao.gen.bean.BizOffer;
import com.smooth.dao.gen.bean.BizStudent;
import com.smooth.site.sx.mag.biz.applyjob.service.BizJobApplayService;
import com.smooth.site.sx.mag.biz.compcollege.comp.service.PcCollegeCompService;
import com.smooth.site.sx.pc.job.enums.ApplyJobStatus;
import com.smooth.site.sx.pc.job.req.invite.InviteApplyReq;
import com.smooth.site.sx.pc.job.service.PcInviteApplyService;
import com.smooth.site.sx.pc.job.service.PcJobService;
import com.smooth.site.sx.pc.offer.service.PcOfferService;
import com.smooth.sys.pc.vo.ListRsp;

@Controller
@RequestMapping(value = "/pc")
public class PcYCompJobInviteController {
	@Autowired
	PcCollegeCompService pcCollegeCompService;
	@Autowired
	PcJobService pcJobService;
	@Autowired
	PcInviteApplyService pcInviteApplyService;
	@Autowired
	PcOfferService pcOfferService;
	@Autowired
	BizJobApplayService bizJobApplayService;
	@RequestMapping(value = {"c/comp/queryStu"},method = {RequestMethod.POST,RequestMethod.GET})
	@ResponseBody
	public ReturnResult queryCompApply(HttpServletRequest request, HttpServletResponse response) {
		ReturnResult returnResult = new ReturnResult();
		BizCompany secBizCompany = (BizCompany)PcAccountContext.getObj(BizCompany.class);
		List<BizStudent>  blist = pcInviteApplyService.queryCompStudents(secBizCompany.getId());
		returnResult.setData(blist);
		return returnResult;
	}
	
	
	@RequestMapping(value = {"c/comp/sendApply"},method = {RequestMethod.POST,RequestMethod.GET})
	@ResponseBody
	public ReturnResult queryCompApply(String stuIds,HttpServletRequest request, HttpServletResponse response) {
		ReturnResult returnResult = new ReturnResult();
		BizCompany secBizCompany = (BizCompany)PcAccountContext.getObj(BizCompany.class);
		if(stuIds!=null && StringUtils.isNotBlank(stuIds)) {
			List<BizJobApplay> brsp = pcInviteApplyService.sendApplys(stuIds.split(","),secBizCompany);
			returnResult.setData(brsp);
		}
		return returnResult;
	}
	
	@RequestMapping(value = {"c/comp/queryApply"},method = {RequestMethod.POST,RequestMethod.GET})
	@ResponseBody
	public ReturnResult queryApply(InviteApplyReq inviteApplyReq,BindingResult result,HttpServletRequest request, HttpServletResponse response) {
		ReturnResult returnResult = new ReturnResult();
		BizCompany secBizCompany = (BizCompany)PcAccountContext.getObj(BizCompany.class);
		inviteApplyReq.setUid(secBizCompany.getId());
		ListRsp<BizJobApplay> brsp = pcInviteApplyService.queryCompJobs(inviteApplyReq);
		returnResult.setData(brsp);
		return returnResult;
	}
	
}
